#include "serverPool.h"

int initTcp(char *ip,char *port){
    //socket
    int fd=socket(AF_INET,SOCK_STREAM,0);
    //setsockopt
    int flag=1;
    setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&flag,sizeof(flag));
    //初始化
    struct sockaddr_in addr;
    addr.sin_family=AF_INET;
    addr.sin_port=htons(atoi(port));
    addr.sin_addr.s_addr=inet_addr(ip);
    //bind
    bind(fd,(struct sockaddr *)&addr,sizeof(addr));
    //listen
    listen(fd,50);
    return fd;
}
